﻿namespace WorkList
{
    public class Marker
    {
        private List<lessonMarker> lessons;
        private string date;
        private PictureBox pikcha;
        private Label Day;

        public string year { get { return date[6..]; } }

        public string month { get { return date[3..5]; } }

        public string day { get { return date[0..2]; } }

        public PictureBox pictureBox { get { return pikcha; } }

        public Marker(string date, PictureBox pic)
        {
            lessons = new List<lessonMarker>();
            this.date = date;
            pikcha = pic;
            pikcha.MouseEnter += pikcha_mouseEnterEvent;
            pikcha.MouseLeave += pikcha_mouseLeaveEvent;
            pikcha.MouseClick += pikcha_mouseClickEvent;
            MakeDayLabel();
        }

        public void addLesson(lessonMarker ls)
        {
            lessons.Add(ls);
        }

        void MakeDayLabel()
        { 
            Day = new Label();           
            Day.Parent = pikcha;
            Day.AutoSize = true;
            Day.Enabled = false;
            Day.ForeColor = Color.Black;
            Day.Font = new Font("Bahnschrift", 20, FontStyle.Bold);
            Day.Location = new Point(pikcha.Width*7/18 - 25 * (date[0] - '0')*2/7, pikcha.Height / 3);
            Day.Name = date;
            Day.Size = new Size(50, 50);
            Day.Text = date[0] == '0' ? date[1].ToString() : date.Substring(0, 2);
            pikcha.Controls.Add(Day);
        }

        void pikcha_mouseEnterEvent(object sender, EventArgs e)
        {
            pikcha.Cursor = Cursors.Hand;
        }
        void pikcha_mouseLeaveEvent(object sender, EventArgs e)
        {
            pikcha.Cursor = Cursors.Default;
        }
        void pikcha_mouseClickEvent(object sender, EventArgs e)
        {
            DayForm dayForm = new DayForm(lessons);
            dayForm.ShowDialog();
        }
    }
}
